<template>
  <view>
    <view class="container">
      <view class="left">
        <radio @click="radioClick" :checked="goods.goods_state" color="#ffbd27" v-if="isShow"></radio>
        <image :src="goods.goods_small_logo || defaultImage" mode=""></image>
      </view>
      <view class="right">
        <view class="name">{{goods.goods_name}}</view>
        <view class="right-bottom">
          <text class="price">￥{{(goods.goods_price).toFixed(2)}}</text>
          <uni-number-box v-if="isShow" :min="1" :max="10" :value="goods.goods_count" @change="ChangeValue" />
        </view>
      </view>
    </view>
  </view>
</template>

<script>
  export default {
    name:"my-goods",
    props: {
      goods: {
        typeof: Object,
        default: {}
      },
      // 单选框和数字框是否展示
      isShow: {
        typeof: Boolean,
        default: false
      }
    },
    data() {
      return {
        defaultImage: 'https://hbimg.b0.upaiyun.com/5d91b400204034583e9c24dd4b10f225f3e59522ed9-zXPxPI_fw658'
      };
    },
    methods: {
      radioClick(){
        this.$emit('radio-change',{
          goods_id: this.goods.goods_id,
          goods_state: !this.goods.goods_state
        })
      },
      ChangeValue(value){
        this.$emit('num-change', {
          goods_id: this.goods.goods_id,
          goods_count: value
        })
      }
    }
  }
</script>

<style lang="scss">
  .container {
    padding: 20rpx;
    height: 200rpx;
    display: flex;
    justify-content: space-between;
    border-bottom: 2rpx solid #f0f0f0;
    .left {
      display: flex;
      justify-content: space-between;
      align-items: center;
      radio {
        transform: scale(0.8);
      }
      image {
        display: block;
        margin-right: 20rpx;
        width: 200rpx;
        height: 200rpx;
      }
    }
    .right {
      flex: 1;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      .name {
        font-size: 24rpx;
      }
      .right-bottom {
        display: flex;
        justify-content: space-between;
        align-items: center;
        .price {
          color: #ffbd27;
          font-size: 28rpx;
        }
      }
    }
  }
</style>